with ariane.maths.matrix.intf;

generic

  type component_t is private;

  zero : component_t;

  with package imatrix is new ariane.maths.matrix.intf(component_t);

  -- operators defined on component type required by matrix operations
  -- duplicate formal subprogram names indicate that named association
  -- is not allowed and should use parameter passing in explicit order
  -- instead
  with function "+"(lhs, rhs : component_t) return component_t is <>;
  with function "-"(lhs, rhs : component_t) return component_t is <>;
  with function "*"(lhs, rhs : component_t) return component_t is <>;
  with function "-"(c : component_t) return component_t is <>;

package ariane.maths.matrix.any is

  type data_t is array(positive range<>, positive range<>) of component_t;
  type object(m, n : integer) is new imatrix.object with private;

  -- returns an object created with specified size filled with zeros
  function create(m, n : positive) return object;

  -- returns an object created and initialized with given data
  function create(data : data_t) return object;

  -- sets an object with given data
  procedure set(o : in out object; data : data_t);

  -- sets value for the specific component in a matrix objects
  procedure set(o : in out object; i, j : positive; val : component_t);

  -- gets value of the specific component in a matrix object
  function get(o : object; i, j : positive) return component_t;

  -- returns number of rows of the matrix
  function numrows(o : object) return positive;

  -- returns number of columns of the matrix
  function numcols(o : object) return positive;

  -- returns the sum of two matrix objects of same dimensions
  function "+"(lhs, rhs : object) return object;

  -- returns the difference of two matrix objects of same dimensions
  function "-"(lhs, rhs : object) return object;

  -- returns the product of two multipliable matrix objects
  function "*"(lhs, rhs : object) return object;

  -- returns the negative of a matrix object
  function "-"(o : object) return object;

private
  type object(m, n : integer) is new imatrix.object with record
    data : data_t(1..m, 1..n);
  end record;

end ariane.maths.matrix.any;
